
package jtrimet;

import junit.framework.TestCase;

import java.util.*;

public class TrimetTest extends TestCase {

	static
	{
		System.getProperties().setProperty("org.apache.commons.logging.simplelog.defaultlog", "debug");
		System.getProperties().setProperty("org.apache.commons.logging.Log", "org.apache.commons.logging.impl.SimpleLog");
	}

	public void testNearbyStops() throws Exception
	{
		TrimetClient trimet = new TrimetClient();
		List<Location> stops = trimet.getNearbyStops(
												"45.516796999998", 
												"-122.67889999998", 
												100 /* meters */);
		
		for (Location stop : stops)
		{
			printLocation(stop);
		}
	}
	
	public void testArrivals() throws Exception
	{
		TrimetClient trimet = new TrimetClient();
		
		List<Location> locations = trimet.getArrivalInformation("5020", "12768", "10579");

		for (Location loc : locations)
		{
			List<Arrival> arrivals = loc.getArrivals();
			
			System.out.println("\nLocation id: " + loc.getLocationId());
			
			for (Arrival a : arrivals)
			{
				assertEquals(loc.getLocationId(), a.getLocationId());

				assertNotNull(a.getRoute());
				
				System.out.println("Bus " + a.getRoute() 
							+ " scheduled arrival: " 
							+ Util.getDateText(a.getScheduledStopTime())
							+ ", estimated: " + Util.getDateText(a.getEstimatedStopTime())
							+ " [" + a.getStatus() + "]");
			}
				
		}
		
	
		
	}

	
	public void testSchedule() throws Exception
	{
		TrimetClient trimet = new TrimetClient();
		
		// todo : List schedule = trimet.getSchedule("5020");
		
		
	}
	
	private static void printLocation(Location loc)
	{
		System.out.println("Location id: " + loc.getLocationId());
		System.out.println("Lat: " + loc.getLatitude());
		System.out.println("Longitude: " + loc.getLongitude());
		
	}
}
